package com.ymatou.iapi.couponmanage.testcase;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.couponmanage.old.parameter.BatchInfo;
import com.ymatou.iapi.couponmanage.parameter.CreateBean;
import com.ymatou.iapi.couponmanage.parameter.CreateCouponBean;
import com.ymatou.iapi.couponmanage.parameter.GetBatchInfoBean;
import com.ymatou.iapi.couponmanage.parameter.SellerCreateBatchBean;
import com.ymatou.iapi.couponmanage.parameter.executeTaskBean;
import com.ymatou.iapi.couponmanage.service.CreateCall;
import com.ymatou.iapi.couponmanage.service.CreateCouponCall;
import com.ymatou.iapi.couponmanage.service.GetBatchInfoCall;
import com.ymatou.iapi.couponmanage.service.SellerCreateBatchCall;
import com.ymatou.iapi.couponmanage.service.executeTaskCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CouponServiceMCallServiceV2;
import com.ymttest.database.model.couponbatch;
import com.ymttest.database.model.couponusecondition;
import com.ymttest.database.sqlwapper.couponbatchWapper;
import com.ymttest.database.sqlwapper.couponsendsubtaskWapper;
import com.ymttest.database.sqlwapper.couponuseconditionWapper;
//import com.ymttest.database.model.YmtCouponBatch;
//import com.ymttest.database.sqlwapper.couponbatchWapper;
/**
*获取批次信息用例
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetBatchInfo{
	private static GetBatchInfoBean getbatchinfoBean;
	private static GetBatchInfoCall getbatchinfoCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取批次信息用例");
	}

	@Before
	public void caseUp() {
		getbatchinfoBean=new GetBatchInfoBean();
		getbatchinfoCall=new GetBatchInfoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getbatchinfoCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_GetBatchInfo_001() {
		Logger.start(true,"获取批次信息-短码");
		try {
			List<couponbatch> list = new couponbatchWapper().getTop1PlatformShortCodeBatchInfo();
             if(list.size()==0)
             {
            	 CouponServiceMCallServiceV2 couponMCallService = new CouponServiceMCallServiceV2();
     			CreateCouponBean createCouponBean = couponMCallService.setDefaultPlatformCreateCouponBeanForConversion();

     			CreateCouponCall createCouponCall = couponMCallService.createPlatformCoupon(createCouponBean);
     		
     			List<String> batchCodes = new ArrayList<>();
     			batchCodes.add(createCouponCall.getBatchCode());

     			CreateBean createBean = couponMCallService.setDefaultRandomCreateBean(batchCodes);
     			CreateCall createCall = couponMCallService.create(createBean);
     			couponbatch couponbatch1 = new couponbatchWapper().selectBybatchCode(createCouponCall.getBatchCode()).get(0);
     			
     			// 这里直接调用job接口生成兑换码
     			List<Map>  tasks=new couponsendsubtaskWapper().selectTaskByTaskTypelimit(3,1);
     			executeTaskCall call=new executeTaskCall();
     			executeTaskBean bean=new executeTaskBean();
     			list = new couponbatchWapper().getTop1PlatformShortCodeBatchInfo();
             }
			getbatchinfoBean.setBatchCode(list.get(0).getBatchCode());
			getbatchinfoCall.setData(getbatchinfoBean);
			getbatchinfoCall.callService();			
			
			VerifyReturn(list.get(0));
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetBatchInfo_002() {
		Logger.start(true,"获取批次信息-链接");
		try {
			List<couponbatch> list = new couponbatchWapper().getTop1PlatformLinkBatchInfo();

			getbatchinfoBean.setBatchCode(list.get(0).getBatchCode().toString());
			getbatchinfoCall.setData(getbatchinfoBean);
			getbatchinfoCall.callService();			
			
			VerifyReturn(list.get(0));
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetBatchInfo_003() {
		Logger.start(true,"获取批次信息-商家优惠券");
		try {
			List<couponbatch> list = new couponbatchWapper().getTop1SellerBatchInfo();

			getbatchinfoBean.setBatchCode(list.get(0).getBatchCode().toString());
			getbatchinfoCall.setData(getbatchinfoBean);
			getbatchinfoCall.callService();			
			
			VerifyReturn(list.get(0));
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetBatchInfo_004() {
		Logger.start(true,"获取批次信息-用于兑换的批次");
		try {
			
			//生成批次及兑换码
			CouponServiceMCallServiceV2 couponCallService = new CouponServiceMCallServiceV2();
			CreateCouponBean createCouponBean = couponCallService.setDefaultPlatformCreateCouponBeanForConversion();

			CreateCouponCall createCouponCall = couponCallService.createPlatformCoupon(createCouponBean);

			CouponServiceMCallServiceV2 mCouponserviceCallService = new CouponServiceMCallServiceV2();

			List<String> batchCodes = new ArrayList<>();
			batchCodes.add(createCouponCall.getBatchCode());

			CreateBean createBean = mCouponserviceCallService.setDefaultRandomCreateBean(batchCodes);
			CreateCall createCall = mCouponserviceCallService.create(createBean);
			
			List<couponbatch> list = new couponbatchWapper().selectBybatchCode(createCouponCall.getBatchCode());

			getbatchinfoBean.setBatchCode(list.get(0).getBatchCode().toString());
			getbatchinfoCall.setData(getbatchinfoBean);
			getbatchinfoCall.callService();			
			
			VerifyReturn(list.get(0));
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetBatchInfo_006() {
		Logger.start(true,"获取批次信息-商家优惠券-分享券");
		try {
			// 分享券	
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellercreatebatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatchBean();
			
			sellercreatebatchBean.setCouponType((byte)2);
			sellercreatebatchBean.setEffectiveDays(5);
			
			
			Date dNow = new Date(); // 当前时间
			Date dBefore = new Date();
			Date dAfter = new Date();

			Calendar calendar1 = Calendar.getInstance(); // 得到日历
			calendar1.setTime(dNow);// 把当前时间赋给日历
			calendar1.add(Calendar.DAY_OF_MONTH, -1); // 
			dBefore = calendar1.getTime(); // 得到前一天的时间

			Calendar calendar2 = Calendar.getInstance(); // 得到日历
			calendar2.setTime(dNow);// 把当前时间赋给日历
			calendar2.add(Calendar.DAY_OF_MONTH, 99999); // 
			dAfter = calendar2.getTime(); // 得到前一天的时间

			sellercreatebatchBean.setEffectiveStartDate(dBefore);
			sellercreatebatchBean.setEffectiveEndDate(dAfter);
		
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellercreatebatchBean);
		
			getbatchinfoBean.setBatchCode(sellerCreateBatchCall.getBatchCode());
			getbatchinfoCall.setData(getbatchinfoBean);
			getbatchinfoCall.callService();			
			
			 Logger.verifyEquals((byte)2, getbatchinfoCall.getBatchInfo().getCouponType(),
		                "验证返回coupontype");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetBatchInfo_007() {
		Logger.start(true,"获取批次信息-商家优惠券-活动优惠券,JIRACONN-23166");
		try {
			// 活动优惠券
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellercreatebatchBean = CouponServiceMCallServiceV2.setDefaultSellerCreateBatch_ActivityBean();
		
			SellerCreateBatchCall sellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellercreatebatchBean);
			List<couponbatch> list = new couponbatchWapper().selectBybatchCode(sellerCreateBatchCall.getBatchCode());
			
			getbatchinfoBean.setBatchCode(sellerCreateBatchCall.getBatchCode());
			getbatchinfoCall.setData(getbatchinfoBean);
			getbatchinfoCall.callService();			
			
			VerifyReturn(list.get(0));
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetBatchInfo_008() {
		Logger.start(true,"获取批次信息-平台优惠券-直播活动优惠券,JIRACONN-26114");
		try {
			// 活动优惠券
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createCouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setLimitLiveProduct(true);
			
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createCouponBean);
			List<couponbatch> list = new couponbatchWapper().selectBybatchCode(createCouponCall.getBatchCode());
			
			getbatchinfoBean.setBatchCode(createCouponCall.getBatchCode());
			getbatchinfoCall.setData(getbatchinfoBean);
			getbatchinfoCall.callService();			
			
			couponbatch couponbatch=list.get(0);
			Logger.verifyEquals(4,couponbatch.getCouponType(), "验证直播时优惠券CouponType=4");
			Logger.verifyEquals(11,couponbatch.getUseConditionType(), "验证直播时优惠券UseConditionType=11");
			VerifyReturn(couponbatch);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetBatchInfo_009() {
		Logger.start(true,"获取批次信息-商家优惠券-直播时优惠券,JIRACONN-26114");
		try {
			// 活动优惠券
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			SellerCreateBatchBean sellercreatebatchBean = new CouponServiceMCallServiceV2().setDefaultSellerCreateBatchBean();
			sellercreatebatchBean.setCouponType((byte)4);
			
			SellerCreateBatchCall SellerCreateBatchCall = CouponServiceMCallServiceV2.SellerCreateBatch(sellercreatebatchBean);
			List<couponbatch> list = new couponbatchWapper().selectBybatchCode(SellerCreateBatchCall.getBatchCode());
			
			getbatchinfoBean.setBatchCode(SellerCreateBatchCall.getBatchCode());
			getbatchinfoCall.setData(getbatchinfoBean);
			getbatchinfoCall.callService();		
			
			couponbatch couponbatch=list.get(0);
			
			Logger.verifyEquals(1,couponbatch.getEffectiveTimeType(),
					"验证买手直播优惠券 对应数据库couponbatch表中sBatchCode=" + couponbatch.getBatchCode()
							+ "的记录中EffectiveTimeType");
			
			Logger.verifyEquals(12,couponbatch.getEffectiveDays(),
					"验证买手直播优惠券 对应数据库couponbatch表中sBatchCode=" + couponbatch.getBatchCode()
							+ "的记录中EffectiveDays");
			
			Logger.verifyEquals(11,couponbatch.getUseConditionType(),
					"验证买手直播优惠券 对应数据库couponbatch表中sBatchCode=" + couponbatch.getBatchCode()
							+ "的记录中UseConditionType");
			
			Logger.verifyEquals(4,couponbatch.getCouponType(),
					"验证买手直播优惠券 对应数据库couponbatch表中sBatchCode=" + couponbatch.getBatchCode()
							+ "的记录中CouponType");
			Logger.verifyEquals(11,getbatchinfoCall.getBatchInfo().getProductLimitType(),
					"验证买手直播优惠券 返回ProductLimitType=11");
			
			VerifyReturn(couponbatch);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetBatchInfo_010() {
		Logger.start(true,"获取批次信息-平台优惠券-有效时间为小时 effectiveTimeType=1,JIRACONN-26114");
		try {
			// 活动优惠券
			CouponServiceMCallServiceV2 CouponServiceMCallServiceV2 = new CouponServiceMCallServiceV2();
			CreateCouponBean createCouponBean = CouponServiceMCallServiceV2.setDefaultPlatformCreateCouponBeanForRecieve();
			createCouponBean.setEffectiveTimeType(1);
			
			CreateCouponCall createCouponCall = CouponServiceMCallServiceV2.createPlatformCoupon(createCouponBean);
			List<couponbatch> list = new couponbatchWapper().selectBybatchCode(createCouponCall.getBatchCode());
			
			getbatchinfoBean.setBatchCode(createCouponCall.getBatchCode());
			getbatchinfoCall.setData(getbatchinfoBean);
			getbatchinfoCall.callService();			
			
			VerifyReturn(list.get(0));
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	private void VerifyReturn(couponbatch item) {
		
        BatchInfo batchInfo = getbatchinfoCall.getBatchInfo();
		checkCouponBatch(item,batchInfo);
        //验证使用条件
        checkcouponusecondition(item.getBatchId(),batchInfo);

    }
	private void checkCouponBatch(couponbatch item,BatchInfo batchInfo)
	{
		 Logger.comment("====方法：验证数据库checkcouponbatch====");
	        Logger.verifyEquals("0", getbatchinfoCall.getCode(),
	                "验证返回code");
	     
	        Logger.verifyEquals("操作成功！",
	                getbatchinfoCall.getMessage(), "验证返回Message");


	        String batchCode = getbatchinfoBean.getBatchCode();

	        Logger.verifyEquals(item.getBatchId(),
	        		batchInfo.getBatchId(),
	                "验证返回BatchCode与数据库中表Ymt_CouponBatch中sBatchCode=" + batchCode
	                        + "记录中iBatchId字段相同");
	        
	        Logger.verifyEquals(item.getUseConditionType(), batchInfo.getProductLimitType(),
					"验证返回字段productLimitType与Ymt_CouponSetting表中UseConditionType一致");
	        
	        Logger.verifyEquals(item.getBatchCode(),
	        		batchInfo.getBatchCode(),
	                "验证返回BatchCode与数据库中表Ymt_CouponBatch中sBatchCode=" + batchCode
	                        + "记录中sBatchCode字段相同");
	        
	        // 验证AcquireStartTime，AcquireEndTime，AcquireCouponMethod
	        SimpleDateFormat time=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:ms"); 
	        if(item.getAcquireStartTime()!=null&&batchInfo.getAcquireStartTime()!=null)
	        {
	        	String acquireStartTime =time.format(item.getAcquireStartTime());
	        	Logger.verifyEquals(acquireStartTime.substring(0, 19).replace(" ", "T"),
	        		batchInfo.getAcquireStartTime(),
	                "验证返回BatchCode与数据库中表Ymt_CouponBatch中sBatchCode=" + batchCode
	                        + "记录中AcquireStartTime字段相同");
	        }
	        if(item.getAcquireEndTime()!=null&&batchInfo.getAcquireEndTime()!=null)
	        {
	        	String acquireEndTime =time.format(item.getAcquireEndTime());
	        	Logger.verifyEquals(acquireEndTime.substring(0, 19).replace(" ", "T"),
	        		batchInfo.getAcquireEndTime(),
	                "验证返回BatchCode与数据库中表Ymt_CouponBatch中sBatchCode=" + batchCode
	                        + "记录中AcquireEndTime字段相同");
	        }
	        // 是否作废
	        if(item.getIsInvalid()==null)
	        {
	        	Logger.verifyEquals(false,
	            		batchInfo.getIsExpire(),
	                    "验证返回IsCancellation与数据库中表Ymt_CouponBatch中sBatchCode=" + batchCode
	                            + "记录中bInvalidStatus字段相同");
	        }
	        else {
	        	Logger.verifyEquals(item.getIsInvalid(),
	            		batchInfo.getIsExpire(),
	                    "验证返回IsCancellation与数据库中表Ymt_CouponBatch中sBatchCode=" + batchCode
	                            + "记录中IsInvalid字段相同");
			}
	        
	     // 是否领完
	        Logger.verifyEquals(item.getTotalNum()==item.getReceivedCount(),
	        		batchInfo.getReceiveOver(),
	                "验证返回IsReceiveOver正确");
	           
	   
	        Logger.verifyEquals(item.getSendType(),
	        		batchInfo.getSendType(),
	                "验证返回SendType与数据库中表Ymt_CouponBatch中sBatchCode=" + batchCode
	                        + "记录中iSendType字段相同");
	        
	        if(item.getEffectiveType()==null)
	        {
	        	Logger.verifyEquals(0,
	        		batchInfo.getEffectiveType(),
	                "验证返回EffectiveType与数据库中表CouponBatch中iEffectiveType字段相同");
	        }
	        else{
	        	   Logger.verifyEquals(item.getEffectiveType(),
	               		batchInfo.getEffectiveType(),
	                       "验证返回EffectiveType与数据库中表CouponBatch中iEffectiveType字段相同");
	        }
	        
	        if(item.getEffectiveValidType()==null)
	        {
	        	 Logger.verifyEquals(0,
	             		batchInfo.getEffectiveValidType(),
	                     "验证返回EffectiveValidType与数据库中表CouponBatch中iEffectiveValidType字段相同");
	             }
	        else
	        {
	        	 Logger.verifyEquals(item.getEffectiveValidType(),
	             		batchInfo.getEffectiveValidType(),
	                     "验证返回EffectiveValidType与数据库中表Ymt_CouponSetting中iEffectiveValidType字段相同");
	        
	        }

	        Logger.verifyEquals(time.format(item.getValidStart()).subSequence(0, 19),
	        		batchInfo.getValidStart().replace("T", " "),
	                "验证返回ValidStart与数据库中表couponbatch中ValidStart字段相同");

	        Logger.verifyEquals(time.format(item.getValidEnd()).subSequence(0, 19),
	        		batchInfo.getValidEnd().replace("T", " "),
	                "验证返回ValidEnd与数据库中表couponbatch中ValidEnd字段相同");
	        
	        if(item.getEffectiveDays()==null)
	        {
	        	Logger.verifyEquals(0,
	        		batchInfo.getEffectiveDays(),
	                "验证返回iEffectiveDays与数据库中表couponbatch中iEffectiveDays字段相同");
	        }
	        else {
	        	Logger.verifyEquals(item.getEffectiveDays().intValue(),
	            		batchInfo.getEffectiveDays(),
	                    "验证返回iEffectiveDays与数据库中表couponbatch中iEffectiveDays字段相同");     
			}
	        
	        Logger.verifyEquals(item.getTotalNum(),
	        		batchInfo.getTotalCount(),
	                "验证返回TotalCount与数据库中表couponbatch中iCouponTotalNum字段相同");
	        
	        Logger.verifyEquals(item.getReceivedCount(),
	        		batchInfo.getReceivedCount(),
	                "验证返回BatchCode与数据库中表couponbatch中ReceivedCount字段相同");
	        
	        if(item.getIsShowInPage()==null)
	        {
	        	Logger.verifyEquals(false,
	        		batchInfo.getIsShowInPage(),
	                "验证返回BatchCode与数据库中表couponbatch中sBatchCode=" + batchCode
	                        + "记录中IsShowInPage字段相同");
	        }
	        else {
	            Logger.verifyEquals(item.getIsShowInPage(),
	            		batchInfo.getIsShowInPage(),
	                    "验证返回BatchCode与数据库中表couponbatch中sBatchCode=" + batchCode
	                            + "记录中IsShowInPage字段相同");
			}
	        
	        Logger.verifyEquals(item.getReceiveUserType(),
	        		batchInfo.getUserType(),
	                "验证返回BatchCode与数据库中表couponbatch中iUserType字段相同");
	        // 验证coupontype-分享券
	     //   int couponType=item.getAcquireMethod()==3?2:1;
	        Logger.verifyEquals((byte)item.getCouponType(),
	        		batchInfo.getCouponType(),
	                 "验证返回BatchCode与数据库中表Ymt_CouponBatch中coupontype字段相同");
	        
	        //活动Id
	        Logger.verifyEquals(item.getCouponTypeBizValue(),
            		batchInfo.getCouponTypeBizValue(),
                    "验证返回BatchCode与数据库中表couponbatch中sBatchCode=" + batchCode
                            + "记录中CouponTypeBizValue字段相同");
	        
	        Logger.verifyEquals(item.getEffectiveTimeType(), batchInfo.getEffectiveTimeType(), 
	        		"验证返回EffectiveTimeType与数据库中couponbatch中sBatchCode=" + batchCode
	        		+"记录中EffectiveTimeType字段相同");
	}
	/**
	 * 
	 * @param batchId
	 * @param item 数据库查询couponbatch
	 * @param batchInfo call返回的batchInfo
	 */
	 private void checkcouponusecondition(int batchId,BatchInfo callbatchInfo)
	    {
	    	 Logger.comment("====方法：验证数据库checkcouponusecondition====");
	    	List<couponusecondition> couponuseconditions=new couponuseconditionWapper().selectByBatchId(batchId);
	    	couponbatch couponbatch= new couponbatchWapper().selectByPrimaryKey(batchId);
	    	if(couponuseconditions.size()==0 &&  couponbatch.getUseConditionType()==9 && couponbatch.getCouponType()!=4)
	    	{
				Logger.verifyEquals(0, couponbatch.getUseConditionType(),
	                    "验证限制类型为通用时 数据库couponbatch表中UseConditionType=0");
	    	}
	           //0:通用 1:指定买手，2：指定商品，3：指定活动，4：指定分类，5：指定国家，6：指定品牌，7：指定国家和分类，8：仅优先商品
	    	//国家和分类
			if(callbatchInfo.getCountrys().isEmpty()==false && callbatchInfo.getProductCategories().isEmpty()==false && couponuseconditions.size()!=0)
			{
				List<couponusecondition> clist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,5);
				List<couponusecondition> pclist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,4);
				String cstr="";
				String pcstr="";
				for(int i=0;i<clist.size();i++)
				{
				  cstr+=clist.get(i).getConditionValue()+",";	  
				}
				for(int i=0;i<pclist.size();i++)
				{
					pcstr+=pclist.get(i).getConditionValue()+",";	  
				}
				cstr=cstr.substring(0, cstr.length()-1);
				pcstr=pcstr.substring(0, pcstr.length()-1);
				 Logger.verifyEquals(callbatchInfo.getCountrys(), cstr, "验证限制类型为指定国家和分类时 返回 Countrys");
				 Logger.verifyEquals(callbatchInfo.getProductCategories(), pcstr, "验证限制类型为指定国家和分类时 返回 ProductCategories");
			    Logger.verifyEquals(7, couponbatch.getUseConditionType(), "验证限制类型为指定国家和分类时 数据库couponbatch表中UseConditionType=7");
			    Logger.verifyEquals(7, callbatchInfo.getProductLimitType(), "验证返回的ProductLimitType");
			    return;
			}
			//指定买手
			if(callbatchInfo.getSellerIds().isEmpty()==false && couponuseconditions.size()!=0 && couponbatch.getCouponType()!=(byte)4)
			{
				List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,1);
				String str="";
				for(int j=0;j<cslist.size();j++){
					
					str+=cslist.get(j).getConditionValue()+",";
				}
    			Logger.verifyEquals(callbatchInfo.getSellerIds(), str.substring(0, str.length()-1),
	                      "验证限制类型为指定买手时 返回SellIds");
	            if(couponbatch.getCouponType()==(byte)3)
    			  Logger.verifyEquals(3, callbatchInfo.getProductLimitType(), "验证返回的ProductLimitType");
	            else
	            	 Logger.verifyEquals(1, callbatchInfo.getProductLimitType(), "验证返回的ProductLimitType");
				return;
			}
			//商品
			if(callbatchInfo.getSpecificProducts().isEmpty()==false && couponuseconditions.size()!=0)
			{
				List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,2);
				String str="";
				for(int j=0;j<cslist.size();j++){
					
					str+=cslist.get(j).getConditionValue()+",";
				}
    			Logger.verifyEquals(callbatchInfo.getSpecificProducts(), str.substring(0, str.length()-1),"验证限制类型为指定商品时 返回SpecificProducts");
    			Logger.verifyEquals(2, callbatchInfo.getProductLimitType(), "验证返回的ProductLimitType");
				return;
			}
			
			//分类
			if(callbatchInfo.getActivityIds().isEmpty()==false && couponuseconditions.size()!=0)
			{
				List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,3);
				String str="";
				for(int j=0;j<cslist.size();j++){
					
					str+=cslist.get(j).getConditionValue()+",";
				}
    			Logger.verifyEquals(callbatchInfo.getActivityIds(), str.substring(0, str.length()-1),"验证限制类型为活动时 返回ActivityIds");
    			Logger.verifyEquals(3, callbatchInfo.getProductLimitType(), "验证返回的ProductLimitType");
				return;
			}
			//活动
			if(callbatchInfo.getProductCategories().isEmpty()==false && couponuseconditions.size()!=0)
			{
				List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,4);
				String str="";
				for(int j=0;j<cslist.size();j++){
					
					str+=cslist.get(j).getConditionValue()+",";
				}
    			Logger.verifyEquals(callbatchInfo.getProductCategories(), str.substring(0, str.length()-1),"验证限制类型为活动时 返回ProductCategories");
    			Logger.verifyEquals(4, callbatchInfo.getProductLimitType(), "验证返回的ProductLimitType");
				return;
			}
			//国家
			if(callbatchInfo.getCountrys().isEmpty()==false && couponuseconditions.size()!=0)
			{
				List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,5);
				String str="";
				for(int j=0;j<cslist.size();j++){
					
					str+=cslist.get(j).getConditionValue()+",";
				}
    			Logger.verifyEquals(callbatchInfo.getCountrys(), str.substring(0, str.length()-1),"验证限制类型为国家时 返回Countrys");
    			Logger.verifyEquals(5, callbatchInfo.getProductLimitType(), "验证返回的ProductLimitType");
				return;
			}
			//品牌
			if(callbatchInfo.getProductBrands().isEmpty()==false && couponuseconditions.size()!=0)
			{
				List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,6);
				String str="";
				for(int j=0;j<cslist.size();j++){
					
					str+=cslist.get(j).getConditionValue()+",";
				}
    			Logger.verifyEquals(callbatchInfo.getProductBrands(), str.substring(0, str.length()-1),"验证限制类型为国家时 返回ProductBrands");
    			Logger.verifyEquals(6, callbatchInfo.getProductLimitType(), "验证返回的ProductLimitType");
				return;
			}
			//优先商品
			if(callbatchInfo.getProductLimitType()==8 &&  couponuseconditions.size()!=0)
			{
				Logger.verifyEquals(8, couponbatch.getUseConditionType(),
	                    "验证限制类型为指定优先商品时 数据库couponbatch表中UseConditionType");
				Logger.verifyEquals(8, couponbatch.getUseConditionType(),
	                    "验证限制类型为优选商品时 数据库couponbatch表中UseConditionType=8");
				Logger.verifyEquals(8, callbatchInfo.getProductLimitType(), "验证返回的ProductLimitType");
				return;
			}
	    }
}
